package com.wkt.ggkt.vod.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wkt.ggkt.vo.vod.VideoVisitorCountVo;
import com.wkt.ggkt.vod.entity.VideoVisitor;
import com.wkt.ggkt.vod.mapper.VideoVisitorMapper;
import com.wkt.ggkt.vod.service.VideoVisitorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class VideoVisitorServiceImpl extends ServiceImpl<VideoVisitorMapper, VideoVisitor> implements VideoVisitorService {

    @Resource
    private com.wkt.ggkt.vod.mapper.VideoVisitorMapper videoVisitorMapper;
    @Override
    public Map<String, Object> findCount(Long courseId, String startDate, String endDate) {
        Map<String, Object> resMap = new HashMap<>();
        List<VideoVisitorCountVo> list = videoVisitorMapper.findCount(courseId,startDate,endDate);
        List<String> timeList = list.stream().map(VideoVisitorCountVo::getJoinTime).collect(Collectors.toList());
        List<Integer> countList = list.stream().map(VideoVisitorCountVo::getUserCount).collect(Collectors.toList());
        resMap.put("xList",timeList);
        resMap.put("yList",countList);
        return resMap;
    }
}
